﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for DynamicButtonTemplate
/// </summary>
public class DynamicButtonTemplate : ITemplate
{

	string _ColNameText;


	DataControlRowType _rowType;



	public DynamicButtonTemplate(string ColNameText,  DataControlRowType RowType)
	{

		_ColNameText = ColNameText;

		_rowType = RowType;

	}

	public void InstantiateIn(System.Web.UI.Control container)
	{
		
		container.Controls.Clear();
		switch (_rowType)
		{

			case DataControlRowType.Header:

				

				break;

			case DataControlRowType.DataRow:
				HtmlInputImage image = new HtmlInputImage();
				image.Src = "~/Images/icons/edit.png";
				image.Attributes["onclick"] = "edit(this);return false;";
				image.Attributes["title"] = "Edit";

				container.Controls.Add(image);

				image = new HtmlInputImage();
				image.Src = "~/Images/icons/save_icon.png";
				image.Attributes["onclick"] = "confirmctl(this);return false;";
				image.Style["visibility"] = "hidden";
				image.Style["position"] = "absolute";
				image.Attributes["title"] = "Save";
				container.Controls.Add(image);

				image = new HtmlInputImage();
				image.Src = "~/Images/icons/cancel_icon.png";
				image.Attributes["title"] = "Cancel";
				image.Style["visibility"] = "hidden";
				image.Style["position"] = "absolute";
				image.Attributes["onclick"] = "cancel(this);return false;";

				container.Controls.Add(image);

				break;

			default:

				break;

		}

	}
}